
# 线性回归方程
#
#
#
#
x = [150, 160, 170]
y = [50, 60, 70]
xAvg = (x[0] + x[1] + x[2]) / len(x)
yAvg = (y[0] + y[1] + y[2]) / len(y)


# 计算截距
def beta_0(b1):
    b0 = yAvg - b1 * xAvg
    return b0


# 计算斜率
def beta_1():
    num = 0
    den = 0
    for i in range(0, len(x)):
        num += (x[i] - xAvg) * (y[i] - yAvg)

    print(num)
    for i in range(0, len(x)):
        den += (x[i] - xAvg) * (x[i] - xAvg)
    print(den)
    return num / den


def index():
    print("Hello World")

    b1 = beta_1()
    b0 = beta_0(b1)
    print(b0)
    val = b0 + b1 * 200
    print(val)
    return
